import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
  {
    //登陆页面
    path: '/login',
    name: 'Login',
    component: () => import("../view/login/login.vue")
  },
  {
    path: '/',
    redirect: '/login'
  },
  {
    //主页面
    path: '/home',
    component: () => import("../view/main/main.vue"),
    redirect: "/welcome",
    children: [
      //系统管理
      {
        path: '/welcome',
        component: () => import("../view/system/index.vue"),

      },
      {
        path: '/users',
        component: () => import("../view/system/user/index.vue"),
        meta: { title: '用户管理' }
      },
      {
        path: '/attachments',
        component: () => import("../view/system/accessory/index.vue"),
        meta: { title: '附件管理' }
      },
      {
        path: '/menus',
        component: () => import("../view/system/menu/index.vue"),
        meta: { title: '菜单权限' }
      },
      {
        path: '/roles',
        component: () => import("../view/system/role/index.vue"),
        meta: { title: '角色管理' }
      },
      {
        path: '/departments',
        component: () => import("../view/system/division/index.vue"),
        meta: { title: '部门管理' }
      },
      {
        path: '/notices',
        component: () => import("../view/system/announcement/index.vue"),
        meta: { title: '公告管理' }
      },
      //业务管理
      //物资管理
      {
        path: '/inStocks',
        component: () => import("../view/business/materials/putin.vue"),
        meta: { title: '物资入库' }
      },
      {path:'/add-stocks',component:()=> import ("../view/business/materials/add-stocks.vue"),meta: { title: '入库' }},
      {
        path: '/products',
        component: () => import("../view/business/materials/data.vue"),
        meta: { title: '物资资料' }
      },
      {
        path: '/productCategorys',
        component: () => import("../view/business/materials/classes.vue"),
        meta: { title: '物资类别' }
      },
      {
        path: '/outStocks',
        component: () => import("../view/business/materials/grant.vue"),
        meta: { title: '物资发放' }
      }, 
      {path:'/out-stocks',component:()=> import ("../view/business/materials/out-stocks")},
      {
        path: '/stocks',
        component: () => import("../view/business/materials/storck.vue"),
        meta: { title: '物资库存' }
      },
      //物资流向
      {
        path: '/consumers',
        component: () => import("../view/business/materialsFlow/for.vue"),
        meta: { title: '物资去处' }
      },
      {
        path: '/suppliers',
        component: () => import("../view/business/materialsFlow/source.vue"),
        meta: { title: '物资来源' }
      },

      //健康报备
      {
        path: '/map',
        component: () => import("../view/health/epidemic/epidemic.vue"),
        meta: { title: '全国疫情' }
      },
      {
        path: '/health',
        component: () => import("../view/health/card/card.vue"),
        meta: { title: '健康打卡' }
      },
      {
        path: '/look',
        component: () => import("../view/health/look/look.vue"),
        meta: { title: '查看情况' }
      },
      {
        path: '/rumors',
        component: () => import("../view/health/dispelRumors/dispelRumors.vue"),
        meta: { title: '疫情辟谣' }
      },
      //日志管理
      {
        path: '/loginLog',
        component: () => import("../view/log/loginLog/loginLog.vue"),
        meta: { title: '登入日志' }
      },
      {
        path: '/logs',
        component: () => import("../view/log/operateLog/operateLog.vue"),
        meta: { title: '操作日志' }
      },
      // {path:"*",
      //   component:()=>import([])}
    ]
  }
]
const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})



import store from '../store'//引入store

//路由导航守卫
// router.beforeEach((to, from, next) => {

//   const token = window.localStorage.getItem('JWT_TOKEN');
//   if (to.path == '/login') {
//     if(!token){
//       return next();
//     }else{
//       return next({path: '/home'})
//     }
//   }

//   if(to.path=='/401'){
// 	  return next();
//   }

//   if (!token) {
//     return next('/login');
//   }else {
//     //判断是否有访问该路径的权限
//     const urls =store.state.userInfo.url;
//     //如果是管理员
//     if(store.state.userInfo.isAdmin){
//        return next();
//     }else{
//       if(urls.indexOf(to.path) > -1){
//         //则包含该元素
//         window.sessionStorage.setItem("activePath", to.path);
//         return next();
//       }else{
//         return next("/401");
//       }
//     }
//   }
// })

export default router
